package org.feng.manage.sys;

import org.feng.util.SpringBeanUtils;

import javax.annotation.PostConstruct;

/**
 * 抽象操作处理器模版
 *
 * @author feng
 */
public abstract class AbstractOperateHandlerTemplate<T, R> implements OperateHandler<T, R> {

    protected void init(OperateContext<T> context) {
    }

    protected void after(OperateContext<T> context) {
    }

    public R start(OperateContext<T> context) {
        init(context);
        AbstractOperateHandlerTemplate<T, R> operateHandler = (AbstractOperateHandlerTemplate<T, R>)OperateHandlerFactory.getOperateHandler(context.getOperate());
        R result = operateHandler.handle(context);
        after(context);
        return result;
    }
}
